
using UnityEngine;
/// <summary>
/// 待机状态
/// </summary>

public class IdleState : IState
{
    public IdleState(FSM manager)
    {
        this.manager = manager;
        this.parameter = manager.parameter;
    }

    public override void OnEnter()
    {
        parameter.animator.Play("Idle");
    }
    public override void OnUpdate()
    {
        // parameter.anim.SetFloat("speed", parameter.rb.velocity.magnitude);
        // 如果受伤
        if (parameter.isHurt)
        {
            manager.TransitionState(StateType.Hit);
        }

        //如果输入的移动方向不为0
        if (parameter.inputDirection != Vector2.zero)
        {
            manager.TransitionState(StateType.Move);
        }
        //闪避
        if (parameter.isDodging)
        {
            manager.TransitionState(StateType.Dodge);
        }
        //真正近战攻击
        if (parameter.isMeleeAttack)
        {
            manager.TransitionState(StateType.MeleeAttack);
        }
    }

    public override void OnFixedUpdate() { }

    public override void OnExit() { }
}
